<template>
	<view class="container">
		<!-- Toolbar -->
		<pyh-nv ref="nv" :config="nvConfig"></pyh-nv>
		<!-- Backdrop -->
		<view class="topBackrop"></view>
		<!-- Top -->
		<view class="topContainer" :style="{'padding-top':((actionBarHeight - 5)+'px')}">
			<view class="top uni-flex uni-column">
				<view class="forms" style="padding: 0rpx 35rpx;">
					<!-- 填写企业信息 -->
					<view class="title">
						<image class="title-img" mode="widthFix" src="@/static/ic_place_order_title.png"></image>
						<view class="title-text">填写企业信息</view>
					</view>
					<!-- 企业名称 -->
					<view class="uni-flex forms-item" style="margin-top: 0rpx;">
						<view style="-webkit-flex: 1;flex: 0.1;"></view>
						<view class="forms-item-text" style="-webkit-flex: 1;flex: 1;">企业名称</view>
						<view class="forms-input" style="-webkit-flex: 1;flex: 1;">
							<input class="forms-input-text" placeholder="请填写" @focus="onFocus" @blur="onBlur" />
						</view>
					</view>
					<!-- 统一社会信用代码 -->
					<view class="uni-flex forms-item">
						<view style="-webkit-flex: 1;flex: 0.1;"></view>
						<view class="forms-item-text" style="-webkit-flex: 1;flex: 1;">统一社会信用代码</view>
						<view class="forms-input" style="-webkit-flex: 1;flex: 1;">
							<input class="forms-input-text" placeholder="请填写" @focus="onFocus" @blur="onBlur" />
						</view>
					</view>
					<!-- 法人姓名 -->
					<view class="uni-flex forms-item">
						<view style="-webkit-flex: 1;flex: 0.1;"></view>
						<view class="forms-item-text" style="-webkit-flex: 1;flex: 1;">法人姓名</view>
						<view class="forms-input" style="-webkit-flex: 1;flex: 1;">
							<input class="forms-input-text" placeholder="请填写" @focus="onFocus" @blur="onBlur" />
						</view>
					</view>
					<!-- 营业执照照片 -->
					<view>
						<view class="title-text"
							style="height: 77rpx; font-size: 24rpx; padding-left: 6rpx; justify-content: flex-start;">
							营业执照照片
						</view>
						<image style="width: 100%;" mode="widthFix" src="@/static/mine/ic_mine_business_license.png"
							@tap="chooseEnterpriseImage"></image>
					</view>
					<!-- 填写授权人信息 -->
					<view class="title">
						<image class="title-img" mode="widthFix" src="@/static/ic_place_order_title.png"></image>
						<view class="title-text">填写授权人信息</view>
					</view>
					<!-- 姓名 -->
					<view class="uni-flex forms-item" style="margin-top: 0rpx;">
						<view style="-webkit-flex: 1;flex: 0.1;"></view>
						<view class="forms-item-text" style="-webkit-flex: 1;flex: 1;">姓名</view>
						<view class="forms-input" style="-webkit-flex: 1;flex: 1;">
							<input class="forms-input-text" placeholder="请填写" @focus="onFocus" @blur="onBlur" />
						</view>
					</view>
					<!-- 手机号 -->
					<view class="uni-flex forms-item">
						<view style="-webkit-flex: 1;flex: 0.1;"></view>
						<view class="forms-item-text" style="-webkit-flex: 1;flex: 1;">手机号</view>
						<view class="forms-input" style="-webkit-flex: 1;flex: 1;">
							<input class="forms-input-text" placeholder="请填写" @focus="onFocus" @blur="onBlur" />
						</view>
					</view>
					<!-- 验证码 -->
					<view class="uni-flex forms-item">
						<view style="-webkit-flex: 1;flex: 0.1;"></view>
						<view class="forms-item-text" style="-webkit-flex: 1;flex: 1;">验证码</view>
						<view class="forms-input" style="-webkit-flex: 1;flex: 1;">
							<input class="forms-input-text" placeholder="请填写" @focus="onFocus" @blur="onBlur" />
						</view>
					</view>
					<view style="height: 50rpx; display: flex; align-items: center;">
						<view class="forms-input-text" style="color: rgba(252, 193, 51, 1); font-size: 26rpx;">发送验证码
						</view>
					</view>
					<!-- 授权函 -->
					<view style="padding-bottom: 39rpx;">
						<view class="title-text"
							style="height: 77rpx; font-size: 24rpx; padding-left: 6rpx; justify-content: flex-start;">
							授权函
						</view>
						<view class="uni-flex" style="align-items: flex-end;">
							<image style="width: 280rpx;" mode="widthFix" src="@/static/mine/ic_mine_authorize.png"
								@tap="chooseAuthorizeImage" />
							<view style="color: rgba(116, 148, 248, 1); font-size: 24rpx; margin-left: 20rpx;">
								下载模板
							</view>
						</view>
					</view>
				</view>
				<!-- 保存 -->
				<view class="save">保存</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nvConfig: {
					title: "企业认证",
					bgColor: "#ffffff",
					color: "#000000",
					fixedAssist: {
						hide: true,
					},
					transparent: {
						initColor: "#000000",
					},
				},
			}
		},
		onPageScroll(e) {
			this.$refs.nv.pageScroll(e)
		},
		computed: {
			actionBarHeight() {
				return parseInt(88 * uni.getSystemInfoSync().windowWidth / 750) + uni.getSystemInfoSync().statusBarHeight
			}
		},
		methods: {
			onFocus() {
				this.$mp.page.$getAppWebview().setStyle({
					softinputNavBar: 'none'
				})
			},
			onBlur() {
				this.$mp.page.$getAppWebview().setStyle({
					softinputNavBar: 'auto'
				})
			},
			chooseEnterpriseImage: function() {
				uni.chooseImage({
					count: 1,
					sizeType: ['compressed'],
					sourceType: ['album'],
					success: (res) => {
						console.log('chooseImage success, temp path is', res.tempFilePaths[0])
					},
					fail: (err) => {
						console.log('chooseImage fail', err)
						// #ifdef MP
						uni.getSetting({
							success: (res) => {
								let authStatus = res.authSetting['scope.album'];
								if (!authStatus) {
									uni.showModal({
										title: '授权失败',
										content: '嗨拉需要从您的相册获取图片，请在设置界面打开相关权限',
										success: (res) => {
											if (res.confirm) {
												uni.openSetting()
											}
										}
									})
								}
							}
						})
						// #endif
					}
				})
			},
			chooseAuthorizeImage: function() {
				uni.chooseImage({
					count: 1,
					sizeType: ['compressed'],
					sourceType: ['album'],
					success: (res) => {
						console.log('chooseImage success, temp path is', res.tempFilePaths[0])
					},
					fail: (err) => {
						console.log('chooseImage fail', err)
						// #ifdef MP
						uni.getSetting({
							success: (res) => {
								let authStatus = res.authSetting['scope.album'];
								if (!authStatus) {
									uni.showModal({
										title: '授权失败',
										content: '嗨拉需要从您的相册获取图片，请在设置界面打开相关权限',
										success: (res) => {
											if (res.confirm) {
												uni.openSetting()
											}
										}
									})
								}
							}
						})
						// #endif
					}
				})
			}

		}
	}
</script>

<style>
	@import '@/common/uni-nvue.css';

	page {
		background-color: $uni-bg-color-grey;
	}

	.container {
		width: 100%;
		padding-bottom: 150rpx;
	}

	.topBackrop {
		width: 100%;
		height: 540rpx;
		display: flex;
		position: fixed;
		z-index: 1;
		background-image: linear-gradient(to bottom, #F8D849, #FFED9C);
	}

	.topContainer {
		width: 100%;
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		justify-content: center;
		align-items: center;
	}

	.top {
		width: 100%;
		z-index: 10;
	}

	.title {
		width: 100%;
		height: 89rpx;
		display: flex;
		align-items: center;
	}

	.title-img {
		width: 17rpx;
	}

	.title-text {
		height: 89rpx;
		display: flex;
		margin-left: 20rpx;
		font-size: 28rpx;
		font-weight: bold;
		color: $uni-text-color;
		justify-content: center;
		align-items: center;
	}

	.forms {
		margin: 0rpx 25rpx;
		margin-top: 20rpx;
		background-color: white;
		border-radius: 20rpx;
		box-sizing: border-box;
		align-items: center;
	}

	.forms-item {
		margin-top: 15rpx;
		width: 100%;
		height: 88rpx;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #F6F8FA;
	}

	.forms-item-text {
		height: 100%;
		text-align: start;
		color: $uni-text-color;
		padding: 0rpx 6rpx;
		display: flex;
		align-items: center;
		font-size: 26rpx;
	}

	.forms-input {
		height: 100%;
		color: #333333;
		justify-content: center;
		display: flex;
		align-items: center;
	}

	.forms-input-text {
		width: 100%;
		padding: 0rpx 30rpx;
		text-align: right;
		font-size: 26rpx;
		color: $uni-text-color;
	}

	.save {
		display: flex;
		justify-content: center;
		margin: 30rpx 40rpx;
		align-items: center;
		height: 90rpx;
		background-color: rgba(248, 216, 73, 1);
		border-radius: 50rpx;
		color: rgba(41, 43, 53, 1);
		font-size: 28rpx;
		font-weight: bold;
	}
</style>